<?php
$this->title = "A-PMS项目管理系统-修改协同";
$this->registerCssFile('/css/list/timePicker/jquery-ui-timepicker-addon.css');
$this->registerCssFile('/css/list/timePicker/jquery-ui-1.11.4.css');
$this->registerCssFile('/css/officeHall/uploadAssetPackage/initiateSynergy.css');
$this->registerCssFile('/css/adminLTE/select2.min.css',['depends'=>'\yii\bootstrap\BootstrapAsset']);
$this->registerCssFile('/css/adminLTE/font-awesome.min.css',['depends'=>'\yii\bootstrap\BootstrapAsset']);
$this->registerCssFile('/css/adminLTE/daterangepicker.css',['depends'=>'\yii\bootstrap\BootstrapAsset']);


$this->registerJsFile('/js/officeHall/uploadAssetPackage/initiateSynergy.js');
$this->registerJsFile('/css/list/timePicker/jquery-ui-1.11.4.js');
$this->registerJsFile('/css/list/timePicker/zh-CN.js');
$this->registerJsFile('/js/adminLTE/bootstrap.min.js');
$this->registerJsFile('/js/adminLTE/select2.full.min.js');
$this->registerJsFile('/js/adminLTE/moment.min.js');
$this->registerJsFile('/js/adminLTE/daterangepicker.js');
$this->registerJsFile('/css/list/timePicker/jquery-ui-timepicker-addon.js');
$this->registerJsFile('/css/list/timePicker/jquery-ui-timepicker-zh-CN.js');
?>
<style>
    .liandiv {
        margin-left: -50px;
    }
    .xy {
        position: absolute;
        top:0%;
        left: 0%;
        transform: translate(0%,0%);
    }
    
    .select2-selection {
    	border-color: #E2E2E2!important;
    	border-radius: 2px!important;
    	height: 30px;
    }
    
    .select2-container--default .select2-selection--multiple .select2-selection__choice {
    	margin-top: 3px;
    	height: 24px;
    	border-radius: 2px;
    	border: none!important;
    }
    
    .myFrom .formOne .formOneUl li span  {
    	line-height: 24px;
    }
    
    .mask  {
    	padding-bottom: 40px;
    }
    
    
   .otherText {
    height: 70px;
    border: 2px solid rgb(204, 204, 204);
    margin: 0px 0px 0px 10px;
    border-radius: 2px;
    width: 390px;
    width: 70%;
    border-color: #e2e2e2;
    border: 1px solid #e2e2e2;
    border-radius: 2px;
    resize: none;
    padding: 3px 5px;
}
.wrap {
	background: #fff;
}

.maskTwo .myFrom .lastNextStep {
    padding-bottom: 50px;
}
</style>
<!--//遮罩层-->
<!--//1.团队组成-->
<div class="container">
    <div class="rwo">
        <div class="mask xy" style="display: block" id="mask">
            <div class="myFrom">
                <p>1.团队组成</p>
                <form class="formOne">
                    <ul class="formOneUl clearfix">

                        <!--资产包id-->
                        <input type="text" hidden id="package_id"
                               value="<?= $package_id ?>">
                        <!--资产包详情id-->
                        <input type="text" hidden id="package_plan_id"
                               value="<?= !empty($workman['id']) ? $workman['id'] : 0; ?>">
                        <li class="clearfix" style="display: none;">
                            <span class="pull-left"></span>
                            <input type="text" hidden value="<?= !empty($workman['ownerId']) ? $workman['ownerId'] : $ownerName['id']; ?>"
                                   name="uploaded_by_id" class="inputText pull-left" id="uploaded_by_id">
                            <input type="text" hidden list="assetPackageTitle" name="uploaded_by_name" id="uploaded_by_name"
                                   placeholder=""  class="form-control"
                                   value="<?= !empty($workman['description']) ? $workman['description'] . '-' : '' ?><?= !empty($workman['ownerUserName']) ? $workman['ownerUserName'] : $ownerName['realname']; ?>"/>

                            <!--											<button type="button" class="btn  determine btn-success">-->
                            <!--												确定-->
                            <!--											</button>-->
                            <!--											<datalist id="assetPackageTitle">-->
                            <!--												<option value="12提示1"></option>-->
                            <!--												<option value="14提示2"></option>-->
                            <!--												<option value="15提示3"></option>-->
                            <!--											</datalist>-->
                        </li>
                        <div class="box-body">
                            <div class="row">
                                <div class="col-xs-3">
                                    <span style="line-height: 30px;color: #333;font-weight: bold;display: inline-block;font-size: 14px;">上传人</span>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group liandiv">
                                        <select disabled="disabled" style="height: 33px;width:100%;" class="form-control" id="owner" multiple="multiple" data-placeholder="<?= !empty($workman['description']) ? $workman['description'] . '-' : '' ?><?= !empty($workman['ownerUserName']) ? $workman['ownerUserName'] : $ownerName['realname']; ?>" name="realname" style="width: 100%;" >
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="box-body">
                            <div class="row">
                                <div class="col-xs-3">
                                    <span style="line-height: 30px;color: #333;font-weight: bold;display: inline-block;font-size: 14px;">项目总监</span>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group liandiv">
                                        <select class="form-control" id="zongjian"   data-placeholder="" name="zongjian" style="width: 100%;" >
                                            <option DataKeyField='' value='请选择'>请选择</option>
                                            <?php
                                            $leader_idArr = array_filter(explode(',',$zongjian_id));
                                            if (!empty($leader_idArr)){
                                                foreach ($leader_idArr as $k1 => $v1) {
                                                    foreach ($zongjianName as $k => $v) {
                                                        if ($v1 == $v['id']){
                                                            unset($zongjianName[$k]);
                                                        }
                                                    }
                                                }
                                                foreach ($zongjianName as $k => $v) {
                                                    echo "<option DataKeyField='" . $v['id'] . "' value='" . $v['realname'] . "'>".$v['realname']."</option>";
                                                }
                                            }else{
                                                foreach ($zongjianName as $k => $v) {
                                                    echo "<option DataKeyField='" . $v['id'] . "' value='" . $v['realname'] . "'>".$v['realname']."</option>";
                                                }
                                            }
                                            ?>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="box-body">
                            <div class="row">
                                <div class="col-xs-3">
                                    <span style="line-height: 30px;color: #333;font-weight: bold;display: inline-block;font-size: 14px;">资产包负责人</span>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group liandiv">
                                        <select class="form-control" id="realname"   data-placeholder="" name="realname" style="width: 100%;" >
                                            <option DataKeyField='' value='请选择'>请选择</option>
                                            <?php
                                            $leader_idArr = array_filter(explode(',',$leader_id));
                                            if (!empty($leader_idArr)){
                                                foreach ($leader_idArr as $k1 => $v1) {
                                                    foreach ($userNameAndID as $k => $v) {
                                                        if ($v1 == $v['id']){
                                                              unset($userNameAndID[$k]);
                                                        }
                                                    }
                                                }
                                                foreach ($userNameAndID as $k => $v) {
                                                    echo "<option DataKeyField='" . $v['id'] . "' value='" . $v['realname'] . "'>".$v['realname']."</option>";
                                                }
                                            }else{
                                                foreach ($userNameAndID as $k => $v) {
                                                    echo "<option DataKeyField='" . $v['id'] . "' value='" . $v['realname'] . "'>".$v['realname']."</option>";
                                                }
                                            }
                                            ?>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="box-body">
                            <div class="row">
                                <div class="col-xs-3">
                                    <span style="line-height: 30px;color: #333;font-weight: bold;display: inline-block;font-size: 14px;">预评估</span>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group liandiv">
                                        <select class="form-control select4" multiple="multiple" data-placeholder=""  name="pre_evaluation_name"  style="width: 100%;">
                                            <?php
                                            $pre_evaluationArr = array_filter(explode(',',$pre_evaluation_id));
                                            if (!empty($pre_evaluationArr)){
                                                foreach ($pre_evaluationArr as $k1 => $v1) {
                                                    foreach ($userNameAndID as $k => $v) {
                                                        if ($v1 == $v['id']){
                                                            unset($userNameAndID[$k]);
                                                        }
                                                    }
                                                }
                                                foreach ($userNameAndID as $k => $v) {
                                                    echo "<option DataKeyField='" . $v['id'] . "' value='" . $v['realname'] . "'>".$v['realname']."</option>";
                                                }
                                            }else{
                                                foreach ($userNameAndID as $k => $v) {
                                                    echo "<option DataKeyField='" . $v['id'] . "' value='" . $v['realname'] . "'>".$v['realname']."</option>";
                                                }
                                            }
                                            ?>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="box-body">
                            <div class="row">
                                <div class="col-xs-3">
                                    <span style="line-height: 30px;color: #333;font-weight: bold;display: inline-block;font-size: 14px;">尽调人员</span>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group liandiv">
                                        <select class="form-control select3" multiple="multiple" data-placeholder="" name="due_diligence_name" style="width: 100%;" >
                                            <?php
                                            $due_diligenceArr = array_filter(explode(',', $due_diligence_id));
                                            if (!empty($due_diligenceArr)) {
                                                foreach ($due_diligenceArr as $k1 => $v1) {
                                                    foreach ($userNameAndID as $k => $v) {
                                                        if ($v1 == $v['id']){
                                                            unset($userNameAndID[$k]);
                                                        }
                                                    }
                                                }
                                                foreach ($userNameAndID as $k => $v) {
                                                    echo "<option DataKeyField='" . $v['id'] . "' value='" . $v['realname'] . "'>".$v['realname']."</option>";
                                                }
                                            } else {
                                                foreach ($userNameAndID as $k => $v) {
                                                    echo "<option DataKeyField='" . $v['id'] . "' value='" . $v['realname'] . "'>" . $v['realname'] . "</option>";
                                                }
                                            }
                                            ?>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="box-body">
                            <div class="row">
                                <div class="col-md-3">
                                    <span style="line-height: 30px;color: #333;font-weight: bold;display: inline-block;font-size: 14px;">其他说明</span>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group" style="margin-left: 125px;margin-top: -26px;width: 79%;">
                                    	<textarea name=""  rows="" name="other_team_notes" cols="" placeholder="其他说明"  class="inputText otherText textarea-edit pull-left" id="other_team_notes"><?= !empty($workman['other_team_notes']) ? $workman['other_team_notes'] : ''; ?></textarea>
                                        <!--<input type="text" placeholder="其他说明" name="other_team_notes" style="    height: 42px;
    border: 2px solid #ccc;
    margin-left: 10px;border-radius:2px;" id="other_team_notes"
                                               class="inputText pull-left"
                                               value="<?= !empty($workman['other_team_notes']) ? $workman['other_team_notes'] : ''; ?>"/>-->
                                    </div>
                                </div>
                            </div>

                        </div>

                    </ul>
                </form>

                <div class="lastNextStep" id="nextButton">
                    <button type="button" class="btn nextStep btn-primary  active pull-right">下一步</button>
                </div>

            </div>
        </div>
    </div>
</div>

	<!-- textarea 高度设置对比div -->

<div style="max-height: 1px; overflow: hidden;">
	<div id="d1" style="visibility:hidden;min-height: 80px;"></div>
</div>
<!--工作计划-->
<?= $this->render('work-plan', [
    'initiationPlan'=>$initiationPlan,
]); ?>

<script>
	
	// textarea 高度展示问题
	    $(".textarea-edit").keyup(function(){
	      var val = $(this).val();
	      var ht = $(this).width();
	       $("#d1").width(ht);
	      $("#d1").html("<pre>" +val+" "+"</pre>");
	      var h = $("#d1").height() ;
	      $(this).height(h);
	    });
    var userData = '<?php echo json_encode($userNameAndID);?>';
    // 单击确定
    var JsonToUserData = JSON.parse( userData );
    // console.log(JsonToUserData);
    var UserId = ',';
    var buttonId = '';
    window.onload = function () {
    }
    function delPlan(PlanId) {
        $.post('/package-initiation-plan/del-work-plan',{'workId':PlanId},function (res) {

        })
    }
    $(function () {
        var pre_evaluation_name = JSON.parse('<?= $pre_evaluation_name ?>');
        var pre_evaluation_id = $.grep( '<?= $pre_evaluation_id ?>'.split(','), function(n) {return $.trim(n).length > 0;});
        var due_diligence_name = JSON.parse('<?= $due_diligence_name ?>');
        var due_diligence_id = $.grep( '<?= $due_diligence_id ?>'.split(','), function(n) {return $.trim(n).length > 0;});
        var leader_name = JSON.parse('<?= $leader_name ?>');
        var leader_id = $.grep( '<?= $leader_id ?>'.split(','), function(n) {return $.trim(n).length > 0;});
        var zongjian_name = JSON.parse('<?= $zongjian_name ?>');
        var zongjian_id = $.grep( '<?= $zongjian_id ?>'.split(','), function(n) {return $.trim(n).length > 0;});
        //调用关联数据
        $('.select4').select2({
            data: pre_evaluation_name,
        });
        $('.select4').select2({}).val(pre_evaluation_id).trigger('change');
        $('.select3').select2({
            data: due_diligence_name,
        });
        $('.select3').select2({}).val(due_diligence_id).trigger('change');
        $('#realname').select2({
            data: leader_name,
        });
        $('#realname').select2('val',leader_id);
        $('#owner').select2({
        });
        $('#zongjian').select2({
            data: zongjian_name,
        });
        $('#zongjian').select2('val',zongjian_id);
        //时间
        //Date range picker
        $('.reservation').daterangepicker()
        //Date range picker with time picker
        $('#reservationtime').daterangepicker({ timePicker: true, timePickerIncrement: 30, format: 'MM/DD/YYYY h:mm A' })
    })
    //高亮展示select2-selection
     $(".textarea-edit").on("focus",function(){
     	var val = $(this).val();
	      var ht = $(this).width();
	       $("#d1").width(ht);
	      $("#d1").html("<pre>" +val+" "+"</pre>");
	      var h = $("#d1").height() ;
	      $(this).height(h);
     	
			$(this).css({
						'border':'1px solid #2194f1'
			})
		})
	$(".textarea-edit").on("blur",function(){
		$(this).css({
					'border':'1px solid #e2e2e2'
		})
	})
		
	//单击下一步和上一步
	 $('.lastNextStep').on('click','.nextStep',function(){
	 	$('.mask').hide();
	 })
	  $('.lastNextStep').on('click','.lastStep',function(){
	 	$('.mask').show();
	 	$('.lastNextStep').show()
	 })
	
</script>
